package com.tt.cards.User.entity;

import com.tt.cards.Company.entity.Company;
import com.tt.cards.Currency.entity.Currency;
import com.tt.cards.Warehouse.entity.Warehouse;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name="WUSER")
public class Wuser implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="ID", nullable=false)
    private Long id;
    @Column(name="NAME", nullable=false, unique=true)
    private String name;
    @Column(name="DESCRIPTION")
    private String description;	
    @Column(name="WUSERROLE", nullable=false)
    @Enumerated(EnumType.STRING)
    private WuserRole wuserRole;
    @Column(name="EMAIL", nullable=false)
    private String email;
    @Column(name="PASSWORD", nullable=false)
    private String password;
    @JoinColumn(name="COMPANYBYDEFAULT")
    @OneToOne
    private Company CompanyByDefault;
    @JoinColumn(name="WAREHOUSEBYDEFAULT")
    @OneToOne
    private Warehouse WarehouseByDefault;
    @JoinColumn(name="CURRENCYBYDEFAULT")
    @OneToOne
    private Currency CurrencyByDefault;
    @Column(name="SUSPENDED")
    private boolean suspended;

    public Wuser() {
    }

    public Company getCompanyByDefault() {
        return CompanyByDefault;
    }

    public void setCompanyByDefault(Company CompanyByDefault) {
        this.CompanyByDefault = CompanyByDefault;
    }

    public Currency getCurrencyByDefault() {
        return CurrencyByDefault;
    }

    public void setCurrencyByDefault(Currency CurrencyByDefault) {
        this.CurrencyByDefault = CurrencyByDefault;
    }

    public Warehouse getWarehouseByDefault() {
        return WarehouseByDefault;
    }

    public void setWarehouseByDefault(Warehouse WarehouseByDefault) {
        this.WarehouseByDefault = WarehouseByDefault;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Boolean getSuspended() {
        return suspended;
    }

    public void setSuspended(Boolean suspended) {
        this.suspended = suspended;
    }

    public WuserRole getWuserRole() {
        return wuserRole;
    }

    public void setWuserRole(WuserRole wuserRole) {
        this.wuserRole = wuserRole;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Wuser)) {
            return false;
        }
        Wuser other = (Wuser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return name;
    }    
        
}
